package cn.homework.commonMessage.Sync;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer {

    public static void main(String[] args) throws Exception{

        DefaultMQProducer producer = new DefaultMQProducer("MQ-message-Producer");
        producer.setNamesrvAddr("127.1.1.1:9876");
        producer.start();
        Message message = new Message("Sync-message","top-01","我是同步消息".getBytes(StandardCharsets.UTF_8));
        SendResult sendResult = producer.send(message);
        System.out.println(sendResult);
        producer.shutdown();

    }
}
